# Use base image.
FROM alpine:3.21

# Use www-data user and group.
#
# - group=www-data
# - user=www-data
RUN adduser -u 82 -D -S -G www-data www-data && \
    mkdir -p /data && chown -R www-data:www-data /data && \
    mkdir -p /home/www-data/.ssh && cd /home/www-data/.ssh && \
    echo '# ignore unknown hosts' > config && \
    echo 'StrictHostKeyChecking no' >> config && \
    echo 'UserKnownHostsFile /dev/null' >> config && \
    chown -R www-data:www-data /home/www-data && \
    \
    mkdir -p /root/.ssh && cd /root/.ssh && \
    echo '# ignore unknown hosts' > config && \
    echo 'StrictHostKeyChecking no' >> config && \
    echo 'UserKnownHostsFile /dev/null' >> config && \
    chown -R root:root /root && \
    \
    echo "alias ll='ls -l'" > /etc/profile.d/alias.sh

# Use working directory.
WORKDIR /data

# Use aliyun mirror
RUN echo 'https://mirrors.aliyun.com/alpine/v3.21/main' > /etc/apk/repositories && \
    echo 'https://mirrors.aliyun.com/alpine/v3.21/community' >> /etc/apk/repositories

# Add add required tools.
RUN apk add --no-cache -t .env \
        bash ca-certificates tzdata \
        openssh openssl \
        curl git su-exec && \
    ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
